package com.itheima.bos.interceptor;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
import org.apache.struts2.ServletActionContext;

/**
 * Created by Mr.King on 2017/3/8.
 */
public class BOSLoginInterceptor extends MethodFilterInterceptor {

    @Override
    protected String doIntercept(ActionInvocation actionInvocation) throws Exception {
        Object user = ServletActionContext.getRequest().getSession().getAttribute("user");
        if (user != null){
            return actionInvocation.invoke();
        }
        return "login";
    }
}
